#ifndef __CLIENT__
#define __CLIENT__
#include <my_header.h>
typedef enum {
    SIGN_UP,
    SIGN_IN,
    CD,
    LS,
    PWD,
    MKDIR,
    REMOVE,
    PUTS,
    GETS,
    RMDIR
} cmd_t;

typedef struct cmdInfo_s {
    cmd_t cmd;
    char userName[100];
    char arg[100];
    int argLength;
    char fileName[100];
    off_t fileSize;
    char md5[100]; // 实际只需要32位，puts和gets文件时用
    char cmdPath[100];
    int user_id;
} cmdInfo_t;

typedef struct userInfo_s {
    char userName[100];
    char passWord[100];
} userInfo_t;

typedef struct train_s {
    int length;
    char data[4096];
} train_t;

// 配置文件相关的函数
int configureInit(char *ip, char *port);

//与客户端通信相关的函数
void sendCmdInfo_train(int sockfd, cmdInfo_t *pcmdinfo);//用于发送cmdInfo_t结构体
bool recvYesOrNo(int sockfd);//用于接收客户端发来yes or no信息

// 注册、登录相关函数
void menu();
int logIn(int *sockfd, userInfo_t *user);
int signUp(int *sockfd, userInfo_t *user);
int signIn(int *sockfd, userInfo_t *user);
char *GenerateStr();

// 解析command 相关的函数
int readCommand(char *command, int commandLen);
int analyzeCommand(char *command, int commandLen, char *cmd, int cmdLen, char *arg, int argLen);
int matchCmd(const char *cmd);
int findCmdInterface(int sockfd, const cmd_t cmd, cmdInfo_t *cmdinfo);
// cmd对应的接口函数
int CD_Client(int sockfd, cmdInfo_t *cmdinfo);
int LS_Client(int sockfd, cmdInfo_t *cmdinfo);
int PUTS_Client(int sockfd, cmdInfo_t *cmdinfo);
int GETS_Client(int sockfd, cmdInfo_t *cmdinfo);
int REMOVE_Client(int sockfd, cmdInfo_t *cmdinfo);
int PWD_Client(int sockfd, cmdInfo_t *cmdinfo);
int MKDIR_Client(int sockfd, cmdInfo_t *cmdinfo);

//客户端transFile相关函数
int sendFile(int sockfd, cmdInfo_t *cmdInfo);
int recvFile(int sockfd, cmdInfo_t *cmdInfo);

int getMd5(char* arg, char* md5_str);
char *calculateMd5(const unsigned char *data, size_t len); 
 #endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
